<?php
if(isset($_GET['orderNum']) && isset($_GET['type']) && isset($_GET['userType']) && isset($_GET['userID']))
{
	$file = $_GET['orderNum'].'.pdf'; 
	$path = dirname(__FILE__).DIRECTORY_SEPARATOR.'../report/'.$_GET['userType'].'/'.$_GET['userID'].'/'.$_GET['orderNum'].'/'.$_GET['type'].'/'.$file;	
	if (file_exists($path)) {
		header('Content-Description: File Transfer');
	    header('Content-Type: application/pdf');
	    header('Content-Disposition: attachment; filename='.basename($file));
	    header('Content-Transfer-Encoding: binary');
	    header('Expires: 0');
	    header('Cache-Control: must-revalidate');
	    header('Pragma: public');
	    header('Content-Length: ' . filesize($path));
	    ob_clean();
	    flush();
	    readfile($path);
	    exit;
	}
	else {
		header('HTTP/1.0 404 Not Found');
	    echo "<h1>404 Not Found</h1>";
	    echo "The page that you have requested could not be found.";
	    exit();
		
	}
}
else echo "Can not view pdf file";
?>